package cn.yuan.xiaoyu.newsmodule.fragment;

import android.Manifest;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

import butterknife.OnClick;
import cn.yuan.xiaoyu.R;
import cn.yuan.xiaoyu.commonmodule.fragment.BaseFragment;
import cn.yuan.xiaoyu.testmodule.utils.PermissionsUtils;

/**
 * Created by yukuoyuan on 2017/3/7.
 * 这是一个新闻的视频列表的界面
 */

public class NewsVideosFragment extends BaseFragment implements PermissionsUtils.OnPermissionListener {

    @Override
    public void initdata(Bundle arguments) {

    }

    @Override
    public int getContentLayout() {
        return R.layout.fragment_newsvideo;
    }

    @Override
    protected void bindPresenter() {

    }

    @Override
    protected void initToolbar() {

    }


    @OnClick({R.id.bt_test_01, R.id.bt_test_02})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.bt_test_01:
                PermissionsUtils.instance().requestPermission(getActivity(), Manifest.permission.CALL_PHONE, 111, this);

                break;
            case R.id.bt_test_02:
                break;
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode,
                                           String permissions[], int[] grantResults) {
        PermissionsUtils.instance().onRequestPermissionsResult(requestCode, grantResults, this);
    }

    @Override
    public void onRequestPermissionSuccess(int requestCode) {
        callPhone();

    }

    @Override
    public void onRequestPermissionFailure(int requestCode) {
        showToast(getActivity(), "授权失败");

    }

    public void callPhone() {
        Intent intent = new Intent(Intent.ACTION_CALL);
        Uri data = Uri.parse("tel:" + "10086");
        intent.setData(data);
        startActivity(intent);
    }
}
